import sys
sys.path.insert(0,'../..')
from rmpoly import *
from time import time

from gmpy import mpq
try:
  import psyco
  psyco.full()
except:
  pass

rp1 = RPoly(['x'],10,mpq)
x = rp1.gens()[0]
rp2 = RPoly(['y'],10,rp1)
y = rp2.gens()[0]
rp3 = RPoly(['z'],10,rp2)
z = rp3.gens()[0]

f = open('log','w')
p = mpq(1,111) + mpq(1,137)*x + mpq(1,1003)*y +mpq(128)*z
t0 = time()
p1 = p.miller_pow(32)
t1 = time()
f.write(str(p1))
t2 = time()
f.close
f = open('log')
s = f.read()
p2 = rp3(s)
t3 = time()
assert p1 == p2
print '%s pow %.2f write %.2f read %.2f' % (sys.argv,t1-t0,t2-t1,t3-t2)

